﻿
namespace Service
{
	using System.Linq;
	using Data.Repository;
	using System.Collections.Generic;

	public class PaymentMethodService : IPaymentMethodService
	{
		private IPaymentMethodRepository _paymentMethodRepository;

		#region IPaymentMethodService Members

		public int CreateNewPaymentMethod(Data.Entity.PaymentMethod theNewPaymentMethod)
		{
			if (theNewPaymentMethod == null)
			{
				return 0;
			}

			if (_paymentMethodRepository == null)
			{
				_paymentMethodRepository = new PaymentMethodRepository();
			}

			return _paymentMethodRepository.CreateNewPaymentMethod(theNewPaymentMethod);
		}

		public IList<Data.Entity.PaymentMethod> GetAllPaymentMethod()
		{
			if (_paymentMethodRepository == null)
			{
				_paymentMethodRepository = new PaymentMethodRepository();
			}

			return _paymentMethodRepository.GetAllPaymentMethod();
		}

		public IList<Data.Entity.PaymentStatus> GetAllPaymentStatus()
		{
			if (_paymentMethodRepository == null)
			{
				_paymentMethodRepository = new PaymentMethodRepository();
			}

			return _paymentMethodRepository.GetAllPaymentStatus();
		}

		public int DeletePaymentMethod(int id)
		{
			if (id <= 0)
			{
				return 0;
			}

			if (_paymentMethodRepository == null)
			{
				_paymentMethodRepository = new PaymentMethodRepository();
			}

			return _paymentMethodRepository.DeletePaymentMethod(id);
		}

		public Data.Entity.PaymentMethod GetThePaymentMethod(int id)
		{
			if (id <= 0)
			{
				return null;
			}

			if (_paymentMethodRepository == null)
			{
				_paymentMethodRepository = new PaymentMethodRepository();
			}

			return _paymentMethodRepository.GetThePaymentMethod(id);
		}

		public int UpdatePaymentMethod(Data.Entity.PaymentMethod thePaymentMethod)
		{
			if (thePaymentMethod == null || thePaymentMethod.PaymentMethodID <= 0)
			{
				return 0;
			}

			if (_paymentMethodRepository == null)
			{
				_paymentMethodRepository = new PaymentMethodRepository();
			}

			return _paymentMethodRepository.UpdatePaymentMethod(thePaymentMethod);
		}

		#endregion
	}
}
